<@prefix
    foaf="http://xmlns.com/foaf/0.1/"
    ex="http://id.example.com/"
    exterms="http://id.example.com/vocabulary/"
    rdfs="http://www.w3.org/2000/01/rdf-schema#" @>



<@-- organizational chart (sort of) --@>

<@template type="node_set" flavour="chart"@>
<@-- locate the person who has no bosses and render his/her subordinates --@>
    <@for-node@>
        <@select-stmts subjects="@node" predicates="exterms:boss"@>
            <@no-stmts@>
                <@render-node flavour="chart"@>
            <@/no-stmts@>
        <@/select-stmts@>
    <@/for-node@>
<@/template@>



<@-- recursive rendering of a node in the org chart --@>

<@template type="node" for="foaf:Person" flavour="chart"@>
<div class="chart">
    <@render-node flavour="inline"@>
    <@select-stmts predicates="exterms:boss" objects="@node"@>
        <@subjects@>
            <@sort-nodes predicate="foaf:surname" lang="en"@>
                <@for-node@>
                    <@-- recursive invocation --@>
                    <@render-node flavour="chart"@>
                <@/for-node@>
            <@/sort-nodes@>
        <@/subjects@>
    <@/select-stmts@>
</div>
<@/template@>
